<!-- 修改公司信息 -->
<template>
	<el-dialog title="编辑用户" width="50%" :visible.sync="dialogVisible" :before-close="handleClose">
		<el-form ref="form" :model="form" label-width="120px" :rules="rules">
			<el-form-item label="公司名称" prop="name">
				<el-input v-model="form.name" :disabled="true" style="width: 60%;"></el-input>
			</el-form-item>

			<el-form-item label="创建日期" prop="registerTime">
			    <el-date-picker type="date" placeholder="选择日期"
			    v-model="form.registerTime" value-format="yyyy-MM-dd"
			    :picker-options="pickerOptions" style="width: 60%;"></el-date-picker>
			</el-form-item>

			<el-form-item label="发展历程" prop="history">
				<el-input type="textarea" v-model="form.history" clearable style="width: 60%;"></el-input>
			</el-form-item>

			<el-form-item label="公司成就" prop="achieve">
				<el-input type="textarea" v-model="form.achieve" clearable style="width: 60%;"></el-input>
			</el-form-item>

			<el-form-item label="联系方式" prop="phone">
				<el-input v-model="form.phone" clearable style="width: 60%;"></el-input>
			</el-form-item>

			<el-form-item>
				<el-button type="primary" @click="saveComInfo()">保 存</el-button>
				<el-button @click="reset()">重 置</el-button>
			</el-form-item>
		</el-form>
	</el-dialog>
</template>

<script>
	export default {
		name: 'updateComInfo',
		data() {
			return {
				dialogVisible: false,
				loading: false,
				form: {
					id: 1,
					name: '',
					registerTime: '',
					history: '',
					achieve: '',
					phone: ''
				},
			};
		},
		methods: {
			//关闭页面前的回调
			handleClose(done) {
				if (this.loading) {
					return;
				}
				this.$confirm('确定关闭将不会保存数据？')
					.then(() => {
						this.loading = true;
						this.timer = setTimeout(() => {
							done();
							this.loading = false;
						}, 100);
						this.reset();
					})
					.catch(() => {});
			},
			//关闭会话前重置表单
			reset() {
				this.$refs.form.resetFields();
				this.findComInfo()
			},
			findComInfo(){
				var that = this
				this.$http.get("/comInfoMeg/getComInfo").then(function(res) {
					that.form = res.data.comInfo;
				})
			},
			saveComInfo() {
				var that = this
				this.$http.post("/comInfoMeg/saveComInfo", this.form).then(function(res) {
					if (res.data.code == 200) {
					  that.$message({
					    showClose: true,
					    message: "保存成功",
					    type: 'success'
					  });
					  //整个页面进行刷新
					  window.location.reload();
					}else {
					  that.$message({
					    showClose: true,
					    message:"保存失败",
					    type: 'error'
					  });
					}
				})	  
			}
		},
		created() {
			
		}
	}
</script>

<style>
</style>
